<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数组</title>
    <script>
        // 求最大值
        var arr = [2, 6, 1, 77, 52, 25, 99, 7];
        var max = arr[0];
        for (var index = 1; index < arr.length; index++) {
            if (max < arr[index]) {
                max = arr[index];
            }
        }
        console.log(max);

        // 拼接数组
        var arrStr = ['red', 'green', 'blue', 'pink'];
        // 数组追加
        arrStr[arrStr.length + 1] = 'add';
        var str = '';
        var sep = '!'
        for (let index = 0; index < arrStr.length; index++) {
            str += arrStr[index] + sep;
        }
        console.log(str);

        // 筛选数组
        var arr1 = [2, 0, 6, 1, 77, 0, 52, 25, 7];
        var arr2 = [];
        // var j = 0;

        for (let i = 0; i < arr1.length; i++) {
            if (arr1[i] >= 10) {
                // 利用数组长度扩容
                arr2[arr2.length] = arr1[i];
                // arr2[j++] = arr1[i];
            }
        }
        console.log(arr2);
        console.log(arr2.length);
    </script>
</head>

<body>

</body>

</html>